package com.example.sys.wx.handler;

import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.Map;


/***
 *
 * 用户关注事件
 */
@Service
public class UserSubEventHandler extends AbstractWxMpMessageHandler {

    Logger logger = LoggerFactory.getLogger(getClass());

    @Override
    public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map<String, Object> context, WxMpService wxMpService, WxSessionManager sessionManager) throws WxErrorException {
        return WxMpXmlOutMessage.TEXT().content(this.getWechatOpenProperties().getSubtext()).fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()).build();
    }
}
